home *** CD-ROM | disk | FTP | other *** search
/ Risc World 5 / Risc World 5.iso / SOFTWARE / Issue3 / Games / xrick / !xrick / src / c / e_sbonus < prev    next >
Text File  |  2004-06-24  |  2KB  |  90 lines

  1. /*
  2.  * xrick/src/e_sbonus.c
  3.  *
  4.  * Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
  5.  *
  6.  * The use and distribution terms for this software are contained in the file
  7.  * named README, which can be found in the root of this distribution. By
  8.  * using this software in any fashion, you are agreeing to be bound by the
  9.  * terms of this license.
  10.  *
  11.  * You must not remove this notice, or any other, from this software.
  12.  */
  13.  
  14. #include "system.h"
  15. #include "game.h"
  16. #include "ents.h"
  17. #include "e_sbonus.h"
  18.  
  19. #include "util.h"
  20. #include "maps.h"
  21. #include "e_rick.h"
  22.  
  23.  
  24. /*
  25.  * public vars
  26.  */
  27. U8 e_sbonus_counting = FALSE;
  28. U8 e_sbonus_counter = 0;
  29. U16 e_sbonus_bonus = 0;
  30.  
  31.  
  32. /*
  33.  * Entity action / start counting
  34.  *
  35.  * ASM 2182
  36.  */
  37. void
  38. e_sbonus_start(U8 e)
  39. {
  40.     ent_ents[e].sprite = 0; /* invisible */
  41.     if (u_trigbox(e, ENT_XRICK.x + 0x0C, ENT_XRICK.y + 0x0A)) {
  42.         /* rick is within trigger box */
  43.         ent_ents[e].n = 0;
  44.         e_sbonus_counting = TRUE;  /* 6DD5 */
  45.         e_sbonus_counter = 0x1e;  /* 6DDB */
  46.         e_sbonus_bonus = 2000;    /* 291A-291D */
  47. #ifdef ENABLE_SOUND
  48.         syssnd_play(WAV_SBONUS1, 1);
  49. #endif
  50.     }
  51. }
  52.  
  53.  
  54. /*
  55.  * Entity action / stop counting
  56.  *
  57.  * ASM 2143
  58.  */
  59. void
  60. e_sbonus_stop(U8 e)
  61. {
  62.     ent_ents[e].sprite = 0; /* invisible */
  63.  
  64.     if (!e_sbonus_counting)
  65.         return;
  66.  
  67.     if (u_trigbox(e, ENT_XRICK.x + 0x0C, ENT_XRICK.y + 0x0A)) {
  68.         /* rick is within trigger box */
  69.         e_sbonus_counting = FALSE;  /* stop counting */
  70.         ent_ents[e].n = 0;  /* deactivate entity */
  71.         game_score += e_sbonus_bonus;  /* add bonus to score */
  72. #ifdef ENABLE_SOUND
  73.         syssnd_play(WAV_SBONUS2, 1);
  74. #endif
  75.         /* make sure the entity won't be activated again */
  76.         map_marks[ent_ents[e].mark].ent |= MAP_MARK_NACT;
  77.     }
  78.     else {
  79.         /* keep counting */
  80.         if (--e_sbonus_counter == 0) {
  81.             e_sbonus_counter = 0x1e;
  82.             if (e_sbonus_bonus) e_sbonus_bonus--;
  83.         }
  84.     }
  85. }
  86.  
  87. /* eof */
  88.  
  89.  
  90.